﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using YKhoa_Lib.DAL;

namespace YKhoa_Lib.BLL
{
    public class So_GoiKham
    {
        private int _maGK;
        public int MaGK
        {
            get { return _maGK; }
        }
        private string _tenGoiKham;
        public string TenGoiKham
        {
            get { return _tenGoiKham; }
            set { _tenGoiKham = value; }
        }
        private string _maNV;
        public string MaNV
        {
            get { return _maNV; }
            set { _maNV = value; }
        }

        private List<ChiTiet_GoiKham> _chiTietGoiKhams;
        public List<ChiTiet_GoiKham> ChiTietGoiKhams
        {
            get { return _chiTietGoiKhams; }
        }

        private DAL_SoGoiKham dal_SoGK;
        public So_GoiKham()
        {
            _chiTietGoiKhams = new List<ChiTiet_GoiKham>();
            dal_SoGK = new DAL_SoGoiKham();
        }

        public List<So_GoiKham> LayDanhSachSoGoiKham()
        {
            DataTable dt = dal_SoGK.LayDanhSachSoGoiKham(_maNV);
            List<So_GoiKham> lst = new List<So_GoiKham>();
            So_GoiKham sGK = null;
            foreach(DataRow row in dt.Rows)
            {
                sGK = new So_GoiKham();
                sGK._maGK = Factory.emptyNull(row["MaGK"]) != "" ? int.Parse(row["MaGK"].ToString()) : 0;
                sGK._tenGoiKham = Factory.emptyNull(row["TenGoiKham"]);
                sGK._maNV = _maNV;
                lst.Add(sGK);
            }
            return lst;
        }

        public bool LuuSoGoiKham()
        {
            return dal_SoGK.LuuSoGoiKham(this);
        }
    }
}